<template>
	<view>
		<!-- 搜索框 -->
		<view style="height: 90rpx;background-color: #FFFFFF;">
			<u-search :clearabled="true" :showAction="false" placeholder="请根据公告标题搜索" v-model="noticename" style="height: 110rpx;"  
			@search="findGonggaoName()" >
				
			</u-search>
			<!-- <uni-search-bar placeholder="请根据公告标题搜索" bgColor="#e3e9f0" v-model="noticename" @search="findGonggaoName()" /> -->
		</view>
		<!-- <button  @click="uniShare()">1111111111111</button> -->
		<view class="content">
			<view v-for="(item,index) in gaoList" :key="index" style="width: 90%;height:100%; margin: 0 auto;margin-top: 15rpx;">
				<uni-card :title="item.noticename"  style="border-radius: 15px;" @click="gonggaoInfo(item.noticeid)">
					<u--text class="uni-body" :lines="2" :text="item.announcement">
					</u--text>
					<view  style="float: left; width: 350rpx;margin-top: 5px;">
						<u--text type="info" :size="12"   :text="item.serrname+aa(item.createtime)" ></u--text>
					</view>
					<u-tag text="通知" plain size="mini" type="warning" style="width: 80rpx;margin-top: 5px;"></u-tag>
				</uni-card>				
			</view>
		
		</view>
		
	</view>
</template>

<script>
	import request from '../../../../utils/request.js';
	import uniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
	export default {
		data() {
			return {
				gaoList:[],
				noticename:"",
			}
		},
		onLoad() {
			this.hSelectAllgongao();
		},
		methods: {
			aa(date){
							const dateTime = new Date(date)
							const YY = dateTime.getFullYear()
							const MM =
								dateTime.getMonth() + 1 < 10 ? '0' + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1
							const DD =
								dateTime.getDate() < 10 ? '0' + dateTime.getDate() : dateTime.getDate()
							const hh =
								dateTime.getHours() < 10 ? '0' + dateTime.getHours() : dateTime.getHours()
							const mm =
								dateTime.getMinutes() < 10 ? '0' + dateTime.getMinutes() : dateTime.getMinutes()
							const ss =
								dateTime.getSeconds() < 10 ? '0' + dateTime.getSeconds() : dateTime.getSeconds()
							return `${YY}-${MM}-${DD}`
						},
			// // 测试分享-------------------------------------------
			// uniShare(){
			// 	uni.share({
			// 		provider: "weixin",
			// 		scene: "WXSceneTimeline",
			// 		type: 2,
			// 		imageUrl: "https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/d8590190-4f28-11eb-b680-7980c8a877b8.png",
			// 		success: function (res) {
			// 			console.log("success:" + JSON.stringify(res));
			// 		},
			// 		fail: function (err) {
			// 			console.log("fail:" + JSON.stringify(err));
			// 		}
			// 	})
			// },
			// 分享结束--------------------------------------------
			// 公告详情
			gonggaoInfo(noticeid){
				// console.log(noticeid+"-----s-------------公告id")
				uni.navigateTo({
					url:"./gonggaoInfo?noticeid="+noticeid
				})
			},
			// 根据公告标题搜索
			findGonggaoName(noticename){
				request({
					url:'fragmentary/findGonggaoName?noticename='+this.noticename,
					method:'post',
					success: (res) => {
						this.gaoList=res.data.data.data
						// console.log(this.gaoList+/"-----------------------所有公告")
					},
					fail: (res) => {
						console.log("11111111111111111111111111")
					},
				})
			},
			// 展示所有公告
			hSelectAllgongao(){
				request({
					url:'fragmentary/hSelectAllgongao',
					method:'post',
					success: (res) => {
						this.gaoList=res.data.data.data
					},
					fail: (res) => {
						console.log("11111111111111111111111111")
					},
					
				})
			},
			search(res) {
				uni.showToast({
					title: '搜索：' + res.value,
					icon: 'none'
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
.search-result {
		padding-top: 10px;
		padding-bottom: 20px;
		text-align: center;
	}

	.search-result-text {
		text-align: center;
		font-size: 14px;
		color: #666;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 0px;
	}

	.uni-mt-10 {
		margin-top: 10px;
	}
</style>
